package com.lagou.goods.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.lagou.commen.pojo.Goods;
import com.lagou.commen.pojo.GoodsVO;
import com.lagou.goods.mapper.GoodsMapper;
import com.lagou.goods.service.GoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author 李树飞
 */
@Service
public class GoodsServiceImpl implements GoodsService {

    @Autowired
    private GoodsMapper goodsMapper;

    @Override
    public Goods findById(Integer id) {
        return goodsMapper.selectById(id);
    }

    @Override
    public PageInfo<Goods> selectByPage(GoodsVO goodsVO) {
        //分页
        PageHelper.startPage(goodsVO.getCurrentPage(), goodsVO.getPageSize());
        List<Goods> list = goodsMapper.selectByPage(goodsVO);
        return new PageInfo<>(list);
    }

    @Override
    public int deleteById(Integer id) {
        return goodsMapper.deleteById(id);
    }

    @Override
    public int updateById(Goods goods) {
        return goodsMapper.updateById(goods);
    }
}
